package com.ustudy.entity.ec;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.ustudy.core.dao.support.entity.LongIdEntity;

import com.ustudy.entity.iden.RegUser;

@SuppressWarnings("serial")
@Entity(name="GoodsOrder")
@Table(name="EC_GOODS_ORDER")
public class GoodsOrder extends LongIdEntity {
	
	private String code;
	
	private Long createTime=System.currentTimeMillis();
	
	@ManyToOne(cascade={CascadeType.REFRESH},fetch=FetchType.LAZY)
	@JoinColumn(name="GOODS_ID")
	private Goods goods;
	
	@ManyToOne(cascade={CascadeType.REFRESH},fetch=FetchType.LAZY)
	@JoinColumn(name="BUYER_ID")
	private RegUser buyer;
	
	@Enumerated
	private OrderType orderType=OrderType.PLACE;
	
	private Long flashTime;
	
	@Column
	@Lob
	@Basic(fetch=FetchType.LAZY)
	private String memo;
	
	public static enum OrderType{
		PLACE("下单"),SENDED("已发货"),RECIEVED("已收货"),PAYED("已付款"),RETURN("退货"),remove("取消");
		private final String label;
		private OrderType(String label){
			this.label=label;
		}
		public String getLabel() {
			return label;
		}
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	public Goods getGoods() {
		return goods;
	}

	public void setGoods(Goods goods) {
		this.goods = goods;
	}

	public RegUser getBuyer() {
		return buyer;
	}

	public void setBuyer(RegUser buyer) {
		this.buyer = buyer;
	}

	public OrderType getOrderType() {
		return orderType;
	}

	public void setOrderType(OrderType orderType) {
		this.orderType = orderType;
	}

	public Long getFlashTime() {
		return flashTime;
	}

	public void setFlashTime(Long flashTime) {
		this.flashTime = flashTime;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}
}
